layui.use('table', function(){
	var table = layui.table;
	table.render({
		elem: '#roleList',
		url: ctx + '/admin/sys/role/page.html',
		toolbar: '#gridTool',
		page: true,
		cols: [[ //表头
			{field: 'id', title: 'ID', width: 50},
			{field: 'roleCode', title: '角色代码'},
			{field: 'roleName', title: '角色名称'},
			{field: 'roleDesc', title: '角色备注'},
			{field: 'createId', title: '创建人'},
			{field: 'createTime', title: '创建时间'},
			{field: 'modifyId', title: '修改人'},
			{field: 'modifyTime', title: '修改时间'},
			{field: 'status', title: '数据状态'},
			{fixed: 'right', title:'操作', toolbar: '#lineTool', width:150}
		]]
	});
	
	//头工具栏事件
	table.on('toolbar(roleList)', function(obj) {
		if(obj.event === 'add') {
			add();
		}
	});
	
	// 监听行工具事件
	table.on('tool(roleList)', function(obj) {
		var data = obj.data;
		if (obj.event === 'detail') {
			detail(data.id);
		} else if (obj.event === 'edit') {
			
		} else if (obj.event === 'remove') {
			layer.confirm('确认要删除该行数据吗？', function(index) {
				layer.close(index);
				remove(data.id);
			});
		}
	});
	
	function add() {
		layOpenFromUrl("新增角色", ctx + "/admin/sys/role/addView.html");
	}
	function detail(id) {
		layOpenFromUrl("角色详情", ctx + "/admin/sys/role/detail/" + id + ".html");
	}
	function edit(id) {
		
	}
	function remove(id) {
		
	}
});